
#!/usr/bin/env python3
import json
import pandas as pd
from ..utils import fetch_url, st_get_api

def get_path_delay():
    end_point = 'stats/delays'
    url, time_out = st_get_api(end_point)
    try:
        data = fetch_url(url, time_out)
        df = pd.DataFrame(list(data.items()))
        df.reset_index(drop=True, inplace=True)
        df.columns=['path (src-srcport-dst)', 'path delay (s)']
        return json.dumps(data, indent=4), df
    except Exception as e:
        raise
